Abstract query plan

ABSTRACT

A method and apparatus, and article of manufacture are provided to process an abstract query of a database abstraction constructed over an underlying physical data storage mechanism. The database may comprise a single data source, or a federated source spanning multiple systems. Embodiments of the invention process an abstract query by generating an intermediate representation of the abstract query. In one embodiment, the intermediate representation comprises an abstract query plan. An abstract query plan includes a combination of elements from the data abstraction model and elements relating to the underlying physical data storage mechanism. Once generated, a back-end component may easily traverse the abstract query plan to generate an SQL statement (or other resolved query) corresponding to the abstract query. Further, once constructed, the abstract query plan provides a platform for many different optimizations that may be selected by a user or by the runtime component inspecting the abstract query plan prior to creating the resolved query.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is related to a commonly owned, co-pending U.S. patentapplication Ser. No. 10/083,075, filed Feb. 26, 2002, entitled“Application Portability and Extensibility through Database Schema andQuery Abstraction” which is incorporated herein by reference in itsentirety. This application is also related to a commonly owned,co-pending application entitled, “Dealing with Composite Data throughData Model Entities,” application Ser. No. 10/403,356 filed on Mar. 31,2003 incorporated herein by reference in its entirety.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This invention is related to computer databases. More specifically, thisapplication is related to methods for creating an abstraction of aphysical data storage mechanism and for constructing a resolved query ofthe physical data storage mechanism from an abstract query.

2. Description of the Related Art

Databases are well known systems for information storage and retrieval.The most prevalent type of database in use today is the relationaldatabase, a tabular database in which data is defined so that it can bereorganized and accessed in a number of different ways. A relationaldatabase management system (DBMS) uses relational techniques for storingand retrieving data.

A database schema is used to describe the structure of a database. Forexample, a relational schema describes the set of tables, columns, andprimary and foreign keys defining relationships between different tablesin a relational database. Applications are developed that query dataaccording to the relational schema. For example, relational databasesare commonly accessed using a front-end application configured toperform data access routines, including searching, sorting, and querycomposition routines. At the back-end, software programs control datastorage and respond to queries submitted by users interacting with thefront-end.

Structured Query Language (SQL) is a widely used database language thatprovides a means for data manipulation, and includes commands toretrieve, store, update, and delete data. An SQL query is constructedaccording to the relational schema for a given relational database, andaccording to the explicitly defined SQL grammar. An SQL query comprisesa text string that must strictly conform to the grammar requirements ofthe SQL language and must also be semantically correct to perform asdesired by the user. That is, many syntactically correct SQL statementsmay fail to perform as desired due to semantic errors. Because of thiscomplexity, database query applications are often used to assist a userin composing an SQL query of a relational database.

One issue faced by data mining and database query applications, however,is their close relationship with a given database schema. Thisrelationship makes it difficult to support an application as changes aremade to the corresponding underlying database schema. Further, thistightly bound relationship inhibits the migration of the application toalternative data representations.

Commonly assigned U.S. patent application Ser. No. 10/083,075 (the '075application), filed Feb. 26, 2002, entitled “Application Portability andExtensibility through Database Schema and Query Abstraction”, disclosesa framework for a data abstraction model that provides an abstract viewof a physical data storage mechanism. The framework of the '075application provides a requesting entity (i.e., an end-user or front-endapplication) with an abstract representation of data stored in anunderlying physical storage mechanism, such as a relational database. Inthis way, the requesting entity is decoupled from the underlyingphysical data when accessing the underlying DBMS. Abstract queries basedon the framework can be constructed without regard for the makeup of theunderlying database. Further, changes to the schema for the database donot also require a corresponding change in the query applicationfront-end; rather, the abstraction provided by the framework can bemodified to reflect the changes.

One embodiment of a data abstraction model defines a set of logicalfields, corresponding to a users' substantive view of data, which areloosely coupled to the underlying physical databases storing the data.The logical fields are available for a user to compose queries thatsearch, retrieve, add, and modify data stored in the underlyingdatabase. The abstract query is used to generate an SQL query statementprocessed by a relational DBMS. Additional challenges arise whentransforming an abstract query, which comprises a highly logical view ofdata structured in the form of objects, such as logical fields, into anSQL text string (e.g., a SELECT, INSERT, or DELETE statements). Chiefamong these problems is the difficulty of efficiently generating an SQLquery directly from the abstract query. Different pieces of the abstractquery may relate to one another in non-obvious ways, and therefore, thequery builder must look forward and backward through the abstract queryto correctly build the piece of the query currently being considered.The query builder, however, may not be able to inspect the SQL beinggenerated from the abstract query to determine the information it needs.In particular, this makes it harder for the query builder to determineif the SQL is fully optimized, or to make adjustments in the querydesign. First, the SQL would need to be reparsed, despite it being in afragmented and incomplete state during the query building process.Second, the SQL statement does not always contain all of the informationfrom the abstract query, because some information is lost when theabstract query is converted to SQL.

Accordingly, there is a need for techniques to provide furtherimprovements to efficiently generate and optimize a query of anunderlying physical storage mechanism, such as an SQL query of arelational DBMS, and for abstract query processing techniques generally.

SUMMARY OF THE INVENTION

The present invention generally provides techniques for processing anabstract query. Rather than generate a resolved query statement (e.g.,SQL statement) directly from an abstract query, embodiments of theinvention first generate an intermediate representation of the abstractquery. In one embodiment, the intermediate representation comprises anabstract query plan. The abstract query plan includes a combination ofabstract elements from the data abstraction model and elements relatingto the underlying physical data storage mechanism. For a dataabstraction model constructed over a relational database, an abstractquery plan contains all the information about which relational tablesneed to be available, and how to join the tables together (i.e., therelationships between the tables or between the logical fields,conditions on data retrieved.) In one embodiment, an abstract query planmay be implemented using a tree-type data structure that stores thisinformation. Once generated, a back-end component may traverse theabstract query plan to generate an SQL statement corresponding to theabstract query.

One embodiment of the invention provides a method of accessing data in adatabase. The method generally includes receiving, from a requestingentity, an abstract query composed from a plurality of logical fields,wherein each logical field specifies (i) a name used to identify thelogical field, and (ii) an access method that maps the logical field toa data source in the database. The method generally further includesgenerating, from the abstract query, an intermediate representation ofthe abstract query that indicates the logical fields and access methodsincluded in the abstract query, the data sources within the databasecontaining the data, and the relationships between the data sources inthe database, and generating, from the intermediate representation, aresolved query of the database.

Another embodiment of the invention provides a method of providing anabstraction of a relational database. The method generally includesdefining a data abstraction model, wherein the data abstraction modelcomprises: a plurality of logical fields, wherein each logical fieldidentifies a name for the logical field and an access method maps thelogical field to a data source in the relational database, an indicationof the relationships between logical fields, and a graph representationof the relational database that identifies the relationships betweendata sources in the relational database. The method generally furtherincludes providing a query building interface configured to allow a userto compose an abstract query from the plurality of logical fields andproviding a runtime component configured to process an abstract query togenerate a resolved query of the relational database from the abstractquery.

Another embodiment of the invention provides a method of processing anabstract query. The method generally includes receiving, from arequesting entity, an abstract query composed from a plurality oflogical fields, wherein each logical field specifies (i) a name used toidentify the logical field, (ii) an access method that maps the logicalfield to a data source in a database. The method generally furtherincludes identifying (i) a set of data sources referenced by theplurality of logical fields in the abstract query and (ii) a set ofrelationships between the set of data sources, determining an acyclicgraph representation of the set of data sources and a set ofrelationships between the set of data source and generating an abstractquery plan, and traversing the abstract query plan to generate aresolved query of the data sources. In one embodiment, the abstractquery plan comprises a plurality of table instances, wherein the eachtable instance includes an indication of a data source, each of thelogical fields included in the abstract query that depend on datapresent on the indicated data source, and conditions used to limit thedata selected from the indicated data source, and wherein the abstractquery plan further comprises a set of join relationships that indicatehow the plurality of table instances are related to one another relativeto the abstract query.

Another embodiment of the invention provides a method of processing anabstract query. The method generally comprises, receiving, from arequesting entity, an abstract query composed from a plurality oflogical fields, wherein each logical field specifies (i) a name used toidentify the logical field, (ii) an access method that maps the logicalfield to a data source in a database, and identifying (i) a set of datasources referenced by the plurality of logical fields in the abstractquery and (ii) a set of relationships between the set of data sources.The method generally further comprises, determining an acyclic graphrepresentation of the set of data sources, generating an abstract queryplan, wherein the abstract query plan comprises, (a) a plurality oftable instances, wherein each table instance includes (i) an indicationof a data source; (ii) each of the logical fields included in theabstract query that depend on data present on the indicated data source;and (iii) conditions used to limit the data selected from the indicateddata source; and (b) a set of join relationships that indicate how theplurality of table instances are related to one another. And wherein themethod further comprises, performing at least one optimization of theabstract query plan to generate an optimized abstract query plan, andtraversing the optimized abstract query plan to generate a resolvedquery of the data sources.

Another embodiment of the invention provides a computer-readable mediumcontaining a plurality of instructions which, when executed on acomputer system is configured to perform operations. The operationsgenerally include defining a data abstraction model, wherein the dataabstraction model comprises a plurality of logical fields, wherein eachlogical field identifies a name for the logical field and an accessmethod that maps the logical field to a data source in a relationaldatabase, an indication of the relationships between logical fields, anda graph representation of the relational database that identifies therelationships between data sources in the relational database. Theoperations generally further include providing a query buildinginterface configured to allow the composition of an abstract query fromthe plurality of logical fields, and providing a runtime componentconfigured to process an abstract query to generate a resolved query ofthe relational database from the abstract query.

Another embodiment of the invention provides a system for processing anabstract query. The system generally includes a data abstraction model,wherein the data abstraction model includes (i) a plurality of logicalfields, wherein each logical field specifies (a) a name used to identifythe logical field, and (b) an access method that maps the logical fieldto data in the database, (ii) a graph representation of an underlyingphysical data storage mechanism abstracted by the data abstractionmodel. The system generally further includes a user interface configuredto allow a user to compose an abstract query from the plurality oflogical fields, and a runtime component configured to receive anabstract query, and in response, to generate an abstract query plan, andto traverse the abstract query plan to generate a resolved query. In oneembodiment, the abstract query plan includes (i) a plurality of tableinstances, wherein each table instance includes an indication of a datasource, each of the logical fields included in the abstract query thatdepend on data present on the indicated data source, and conditions usedto limit the data selected from the indicated data source; and theabstract query plan further includes (ii) a set of join relationshipsthat indicate how the plurality of table instances are related to oneanother relative to the abstract query.

BRIEF DESCRIPTION OF THE DRAWINGS

So that the manner in which the above recited features, advantages andobjects of the present invention are attained and can be understood indetail, a more particular description of the invention, brieflysummarized above, may be had by reference to the embodiments thereofwhich are illustrated in the appended drawings.

The appended drawings, however, illustrate typical embodiments of thisinvention and should not, therefore, be considered limiting of itsscope, for the invention may admit to other equally effectiveembodiments.

FIG. 1 illustrates a relational view of software and hardwarecomponents, according to one embodiment of the invention.

FIG. 2A illustrates a relational view of software components, accordingto one embodiment of the invention.

FIG. 2B illustrates an abstract query and corresponding data repositoryabstraction component, according to one embodiment of the invention.

FIG. 3 illustrates a runtime component processing an abstract query bycreating an intermediate representation of the abstract querysubsequently used to create a resolved query, according to oneembodiment of the invention.

FIGS. 4A and 4B illustrate a graph that models the relationships betweentables in an underlying relational database.

FIG. 5 illustrates a table instance data structure component of anabstract query plan, according to one embodiment of the invention.

FIG. 6 illustrates an exemplary abstract query plan, according to oneembodiment of the invention.

FIG. 7 illustrates a method for processing an abstract query, using anabstract query plan intermediate representation of the abstract query,according to one embodiment of the invention.

FIG. 8 illustrates a method for creating a resolved query from anabstract query, according to one embodiment of the invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

The present invention provides methods, systems, and articles ofmanufacture used to create a data abstraction model and to process aquery of the model. The data abstraction model provides an interface tothe data stored in a database that conforms to a user's substantive viewof the data, instead of a view corresponding with the schema of thedatabase. When a user composes an abstract query, embodiments of theinvention provide techniques for transforming between these two views,i.e., for creating a query of the underlying database from the abstractquery. Such a query is sometimes referred to herein as a “resolved”query or “physical” query. In a preferred embodiment, where theunderlying storage mechanism is a relational database, such a querycomprises an SQL query statement. It should be understood, however, thatreferences to specific query languages, such as SQL, are used toillustrate embodiments of the invention and application to other querylanguages is contemplated.

Embodiments of the invention provide a multi-step process to generate aresolved query from an abstract query. In one embodiment, an abstractquery is first used to construct an intermediate representation of theabstract query. This intermediate representation is then used to createa resolved query. In one embodiment, the intermediate representationcomprises an abstract query plan (AQP) that includes a combination ofphysical data (e.g., tables and columns of a relational database) andlogical data (e.g., logical fields defined by a data abstraction model).The abstract query plan describes the relationships and interactionsbetween all parts of the abstract query and corresponding data sourcespresent in the underlying database. The abstract query plan incorporatesinformation about which logical fields are selected from which physicalentities and which conditions are applied to which physical entities.Further, the abstract query plan provides a platform for additionaloptimizations used to generate an improved version of a resolved query.

In the following description, reference is made to embodiments of theinvention. The invention is not, however, limited to any specificallydescribed embodiment. Rather, any combination of the following featuresand elements, whether related to a described embodiment or not,implements and practices the invention. Furthermore, in variousembodiments the invention provides numerous advantages over the priorart. Although embodiments of the invention may achieve advantages overother possible solutions and the prior art, whether a particularadvantage is achieved by a given embodiment does not limit the scope ofthe invention. Thus, the following aspects, features, embodiments andadvantages are illustrative and are not considered elements orlimitations of the appended claims except where explicitly recited in aclaim. Likewise, references to “the invention” shall neither beconstrued as a generalization of any inventive subject matter disclosedherein nor considered an element or limitation of the appended claimsexcept where explicitly recited in a claim.

One embodiment of the invention is implemented as a program product foruse with a computer system such as, for example, the computer system 100shown in FIG. 1 and described below. The program product definesfunctions of the embodiments (including the methods) described hereinand can be contained on a variety of signal-bearing media. Illustrativesignal-bearing media include, without limitation, (i) informationpermanently stored on non-writable storage media (e.g., read-only memorydevices within a computer such as CD-ROM disks readable by a CD-ROMdrive); (ii) alterable information stored on writable storage media(e.g., floppy disks within a diskette drive or hard-disk drive); and(iii) information conveyed across communications media, (e.g., acomputer or telephone network) including wireless communications. Thelatter embodiment specifically includes information shared over theInternet or other large computer networks. Such signal-bearing media,when carrying computer-readable instructions that perform methods of theinvention, represent embodiments of the present invention.

In general, software routines implementing embodiments of the inventionmay be part of an operating system or part of a specific application,component, program, module, object, or sequence of instructions such asan executable script. Such software routines typically comprise aplurality of instructions capable of being performed using a computersystem. Also, programs typically include variables and data structuresthat reside in memory or on storage devices as part of their operation.In addition, various programs described herein may be identified basedupon the application for which they are implemented. Those skilled inthe art recognize, however, that any particular nomenclature or specificapplication that follows facilitates a description of the invention anddoes not limit the invention for use solely with a specific applicationor nomenclature. Furthermore, the functionality of programs describedherein use discrete modules or components interacting with one another.Those skilled in the art recognize, however, that different embodimentsmay combine or merge such components and modules in many different ways.

Physical View of the Environment

FIG. 1 illustrates a networked computer system in a client-serverconfiguration. Client computer systems 105 _(1-N) include a networkinterface allowing them to communicate with other systems over network104. The network 104 may comprise a local area network wherein both theclient system 105 and server system 110 reside in the same generallocation, or may comprise network connections between geographicallydistributed systems, including network connections over the Internet.Client system 105 generally includes a central processing unit (CPU)connected via a bus, to memory and storage (not shown). Client system105 is running an operating system, (e.g., a Linux® distribution,Microsoft Windows®, IBM's AIX®, FreeBSD, and the like) that manages theinteraction between hardware components and higher-level softwareapplications running on client system 105.

In one embodiment, a user establishes a network connection betweenclient system 105 and server system 110. Such a connection may include alogin process wherein a user authenticates the user's identity to theserver system 110 using, for example, a username and password or otherauthentication schemes (e.g., digital certificates or biometricauthentication). Systems that do not require authentication are alsocontemplated.

The server system 110 may include hardware components similar to thoseused by client system 105. Accordingly, the server system 110 generallyincludes a CPU, a memory, and a storage device, coupled to one anotherby a bus (not shown). The server system 110 is also running an operatingsystem, (e.g., a Linux® distribution, Microsoft Windows®, IBM's OS/400®or AIX®, FreeBSD, and the like) that manages the interaction betweenhardware components and higher-level software applications.

The client/server configuration illustrated in FIG. 1, however, ismerely exemplary of one hardware/software configuration. Embodiments ofthe present invention may be implemented using other configurations,regardless of whether the computer systems are complex multi-usercomputing systems, such as a cluster of individual computers connectedby a high-speed network that acts as a single system, single-userworkstations, or network appliances lacking non-volatile storage oftheir own. Additionally, although described herein using a client/serverconfiguration, embodiments employing, distributed computing, gridcomputing, and peer-to-peer processing techniques are contemplated.

In one embodiment, users interact with the server system 110 using agraphical user interface (GUI). In a particular embodiment, GUI contentmay comprise HTML documents (i.e., web-pages) rendered on a clientcomputer system 105 ₁ using web-browser 122. In such an embodiment, theserver system 110 includes a Hypertext Transfer Protocol (http) server118 (e.g., a web server such as the open source Apache web-sever programor IBM's Web Sphere® program) adapted to respond to HTTP requests fromthe client system 105 and to transmit HTML documents to client system105. The web-pages themselves may be static documents stored on serversystem 110 or generated dynamically using application server 112interacting with web-server 118 to service HTTP requests from clientsystem 105.

Alternatively, or in addition, client application 120 may comprise adatabase front-end, or query application program running on clientsystem 105 _(N). The application 120 may allow a user to compose anabstract query and to submit the abstract query for processing to theruntime component 114. The application 120 may include a query-buildinginterface 115. Application 120 and query building interface 115 allow auser to compose an abstract query according to a data abstraction model148 that describes the abstraction created over databases 214.

As illustrated in FIG. 1, server system 110 may further include runtimecomponent 114, DBMS server 116, and data abstraction model 148. Each ofthese components may comprise a software program executing on the serversystem 110. The DBMS server 116 (or servers) generally comprises asoftware application configured to manage databases 214 ₁₋₃. By way ofillustration, the individual databases accessible through DBMS server116 may include a relational database 214 ₂ queried using an SQL query,or an XML database 214 ₁ queried using an XML query. The invention,however, is not limited to any particular physical database storagemechanism and may readily be extended to operate on other suchmechanisms, whether currently known or unknown. Accordingly, datastorage mechanism 214 ₃ illustrates other storage mechanisms managed bya DBMS server 116. Further, databases 214 may exist on the local storagesystem of server system 110, or may be accessed over network 104. Thus,the data abstraction created by data abstraction model 148 may beconstructed over both local and federated database configurations, andcombinations thereof.

In one embodiment, a user composes an abstract query using logicalfields defined by a data abstraction model 148. The data abstractionmodel 148 defines the relationship between each logical field and datafrom an underlying physical database mechanism. In one embodiment, eachlogical field defined by the data abstraction model 148 identifies aname and an access method. The access method identifies the underlyingdatabase (e.g., databases 214 ₁₋₃) where the data is located, as well asthe method of access used to access the data in the underlying physicalstorage mechanism. Embodiments of the data abstraction model, logicalfields, and access methods are described in greater detail below.

Runtime component 114 is configured to generate a query consistent withthe physical representation of the data contained in one or more of thedatabases 214. In other words, the runtime component is the“transformational engine” used to generate the physical query (e.g., anSQL statement) from an abstract query. The runtime component 114 takesan abstract query composed by a user, identifies the informationcorresponding to each logical field included in the query from the dataabstraction model 148, and generates a physical query run by DBMS 116against the underlying physical storage mechanism. In one embodiment,the runtime component 114 takes an abstract query and generates anabstract query plan corresponding to a given query, and then uses theabstract query plan to generate a resolved query. Additionally, theruntime component 114 may be configured to return query results to therequesting entity.

FIG. 2A illustrates a plurality of interrelated components of theinvention, along with the transformation between the abstract viewprovided by the data abstraction model (the left side of FIG. 2A), andthe underlying database mechanism used to store data (the right side ofFIG. 2A).

In one embodiment, a requesting entity (e.g., a user interacting withapplication 115 executing on client system 105) composes an abstractquery 202 using query building interface 120. The query buildinginterface may be provided by the application 115, or may be a web-pagerendered on web browser 122. The resulting query is generally referredto herein as an “abstract query” because it is composed from logicalfields rather than by direct references to data entities in underlyingdatabases 214 ₁₋₃. As a result, abstract queries may be composedindependently from the particular underlying relational database schema.

In one embodiment, the logical fields used to compose the abstract query202 are defined by the data abstraction model 148. In general, the dataabstraction model 148 exposes information as a set of logical fieldsthat may be used within an abstract query to specify criteria 131 fordata selection, and specify the form of result data returned from aquery operation. The runtime component 114 is the bridge between theabstract representation provided by the data abstraction model 148, andthe underlying physical database. For example, the runtime component 114may transform abstract query 202 into an XML query that queries datafrom database 214 ₁, an SQL query of relational database 214 ₂, or otherquery composed according to another physical storage mechanism (whethercurrently known or later developed).

Logical View of the Environment

FIG. 2B illustrates an exemplary abstract query 202. The query includesselection criteria 204 designed to retrieve information about a patientnamed “Mary McGoon.” The particular information to be retrieved isspecified by result criteria 206. In this case, the query retrieves anage and test results for a hemoglobin test. The actual data retrievedmay include data from multiple tests. That is, the query results mayexhibit a one-to-many relationship between the named patient and thetest results for the patient.

In addition, abstract query 202 specifies a model entity 201, asillustrated, a “patient” model entity. Generally, model entities providean additional layer of abstraction representing a composite ofindividual logical fields. Model entities provide end users andapplications a higher level conceptual view that can simplify data queryand modification tasks (i.e., insert, search, and deletion). Inaddition, model entities provide the runtime component 114 with thefocus or perspective for a particular abstract query. In other words,the model entity serves to identify broad categories of data, such as a“patient” data. As an example, the “patient” model entity from abstractquery 202 maps to a group of fields in the database abstraction modelall related to the “patient” model entity and to underlying data sourcescontaining patient-related data.

In one embodiment, a user specifies the model entity is being queried aspart of the query building process. Which model entities are availableis defined by the framework provided by the data abstraction model 148.As described below, the runtime component 114 may use the model entityselected for an abstract to select a root node when constructing anabstract query plan. Model entities may be defined by additionalmetadata included in the data abstraction model 148. Detailed examplesof Model entities are described in further detail in a commonly owned,pending application entitled “Dealing with Composite Data through DataModel Entities,” application Ser. No. 10/403,356 filed on Mar. 31, 2003and incorporated by reference herein in its entirety.

FIG. 2B further illustrates one embodiment of a data abstraction model148 that comprises a plurality of logical field specifications 208₁-₅(five shown by way of example. Collectively, logical fieldspecifications 208 ₁₋₅ create an abstraction over a particular set ofunderlying physical databases and corresponding database schema. Thoseskilled in the art will recognize that multiple data repositoryabstraction models may be constructed over the same set of underlyingphysical storage mechanisms. Accordingly, abstractions may beconstructed to expose different portions of data to different users, orabstractions constructed over the same data may differ, and may becustomized to the needs of a particular user (or group of users).

The logical fields shown in FIG. 2B illustrate an abstractionconstructed over a relational database. That is, the access methodsincluded in field specifications 208 define a mapping between thelogical field and tables and columns from a relational database (e.g.,database 214 ₂ from FIG. 2A). The data abstraction model 148 provides alogical field specification 208 for each logical field available forcomposition of an abstract query (e.g., abstract query 202). The logicalfield specification 208 stores a definition for each logical field, andany associated metadata. As illustrated, each field specification 208identifies a logical field name 210 ₁₋₅ and an associated access method212 ₁₋₅. The runtime component 114 uses the access method to map alogical field to a particular physical data storage mechanism 214.Depending upon the number of different types of logical fields, anynumber of access methods is contemplated. As illustrated in FIG. 2B,access methods for simple fields, filtered fields, and composed fieldsare provided.

Field specifications 208 ₁, 208 ₂ and 208 ₅ each provide a simple accessmethod 212 ₁, 212 ₂, and 212 ₅. The simple access method provides adirect mapping to a particular entity in the underlying physical datarepresentation. When this is a relational database, the simple accessmethod maps the logical field to an identified database table andcolumn. For example, the simple field access method 212, shown in FIG.2B maps the logical field name 210 ₁ (“FirstName”) to a column named“f_name” in a table named “Demographics.” The logical fieldspecification 208 may also include metadata indicating how the logicalfield is related to other entities in the data abstraction model 148.

Field specification 208 ₃ exemplifies a filtered field access method 212₃. Filtered access methods identify an associated physical entity andprovide rules used to define a particular subset of items within thephysical data representation. Consider, for example, a relational tablestoring test results for a plurality of different medical tests. Logicalfields corresponding to each different test may be defined, and thefilter for each different test is used to identify when a particulartest is associated with a logical field. An example is provided in FIG.2B in which the access method for filtered field 212 ₃ maps the logicalfield name 210 ₃ (“Hemoglobin Test”) to a physical entity in a columnnamed “Test_Result” in a table named “Tests” and defines a filter“Test_ID=‘1243.’Accordingly, the filtered field acts as selectioncriteria used to restrict items from a larger set of data, without theuser having to know the specifics of how the data is represented in theunderlying physical storage mechanisms or to specify the selectioncriteria as part of the query building process.

Field specification 208 ₄ exemplifies a composed access method 212 ₄.Composed access methods generate values from one or more physical dataitems, or data returned by other logical fields, using an expressionsupplied as part of the access method definition. In this way,information which does not directly exist in the underlying datarepresentation may be computed and provided to a requesting entity. Inthe example illustrated in FIG. 2B the composed field access method 212₃ maps the logical field “Age” to another logical field 208 ₅ named“birth date” The logical field “birthdate” 210 ₅ maps to a column in thedemographics table. The composition expression is used to compute avalue for the composed field. In this example, an age value is computedby subtracting the current date from the birth date value returned bythe “birth date” logical field.

By way of example, the field specifications 208 of the data repositoryabstraction component 148 shown in FIG. 2B are representative of logicalfields mapped to data represented in the relational data representation214 ₂. However, other instances of the data repository abstractioncomponent 148 or other logical field specifications may map to otherphysical data representations (e.g., databases 214 ₁ or 214 ₃illustrated in FIG. 2A).

An illustrative abstract query corresponding to abstract query 202 isshown in Table I below. In this example, the abstract query 202 isrepresented using XML. In one embodiment, application 115 may beconfigured to generate an XML document to represent an abstract querycomposed by a user interacting with the query building interface 120 orweb browser 122. Those skilled in the art will recognize that XML is awell known language used to facilitate the sharing of structured textand information, other languages, however, may be used.

TABLE I QUERY EXAMPLE 001 <?xml version=“1.0”?> 002 <!--Query stringrepresentation: (FirstName = “Mary” AND LastName = 003 “McGoon”) ORState = “NC”--> 004 <QueryAbstraction> 005 <Selection> 006 <ConditioninternalID=“4”> 007 <Condition field=“FirstName” operator=“EQ”value=“Mary” 008 internalID=“1”/> 009 <Condition field=“LastName”operator=“EQ” value=“McGoon” 010 internalID=“3”relOperator=“AND”></Condition> 011 </Condition> 012 </Selection> 013<Results> 014 <Field name=“Age”/> 015 <Field name=“Hemoglobin_test”/>016 </Results> 017 <Entity name=“Patient” > 018 <EntityFieldrequired=“Hard” > 019 <FieldRef name=“data://Demographic/Patient ID” />020 <Usage type=“query” /> 021 </EntityField> 022 </Entity> 023</QueryAbstraction>

The abstract query shown in Table I includes a selection specification(lines 005-012) containing selection criteria and a resultsspecification (lines 013-016). In one embodiment, a selection criterionconsists of a field name (for a logical field), a comparison operator(=, >, <, etc) and a value expression (what is the field being comparedto). In one embodiment, the result specification is a list of logicalfields that are to be returned as a result of query execution. Theactual data returned is consistent with the selection criteria. Themodel entity “patient” is identified on line 017 and associates themodel entity with the patient ID column of the demographic table (line019).

Abstract Query Processing

FIG. 3 illustrates operations of runtime component 114, according to oneembodiment of the invention. As described above, the runtime component114 is configured to receive an abstract query, and in response, togenerate a query of an underlying physical data storage mechanism, suchas a relational database. Queries may be saved, cached, and shared amongdifferent users. Once completed and selected for execution, the query isdelivered to the runtime component 114. In one embodiment, the query istransmitted across network 104 to system 110 using well-known datacommunications protocols.

Once received, runtime component 114 processes the abstract query 305.In one embodiment, the runtime component 114 receives the abstract query305 in a structured form, such as XML, like the query illustrated inTable I. From abstract query 305, runtime component first builds anintermediate representation of the query. In one embodiment, theintermediate representation comprises an abstract query plan thatincludes a combination of abstract elements from the data abstractionmodel and elements relating to the underlying physical data storagemechanism.

For a data abstraction model constructed over a relational database, anabstract query plan includes all the information about which relationaltables need to be available, and how to join the tables together (i.e.,the relationships between the tables or between the logical fields,conditions on data retrieved.) From this the runtime component generatesan SQL statement 312 used to query database 214.

Constructing an Abstract Query Plan

As described above, an abstract query plan includes the logical fieldsused in an abstract query, indicates the physical data sourcescorresponding to the fields, and how to join data from the required datasources. Accordingly, the runtime component 114 needs to have availablea representation of the structure or schema of the database abstractedby the database abstraction model to process an abstract query.

FIG. 4A illustrates a graph representation 400 of an underlyingdatabase. This representation 400 is used to define the relationshipsbetween data sources in the underlying physical storage mechanism. Inone embodiment, the runtime component 114 uses graph representation 400to identify data sources that contain data relevant to a given abstractquery. The graph representation 400 structure is derived from theunderlying physical database structure being abstracted as part of thedata abstraction model 148 and available to the runtime component 114during query processing.

Where the underlying physical storage mechanism is a relationaldatabase, the relational schema may be used to generate the graphrepresentation 400. Each node 405 (three nodes labeled for illustration)of the graph 400 may represent an actual table from the underlyingrelational schema, or may represent a table defined from one or moreactual tables, such as a database view or a common table expression. Therelationships may also be derived from metadata provided by the dataabstraction model 148 that indicates relationships between differentlogical fields and physical data sources. For example, the dataabstraction model 148 may include a “relations” section that indicatesone-to-one and one-to-many relationships between fields. Connecting thenodes are edges 410. As illustrated, node 1 and node 2 are connected byedge 410 ₁, and node 2 and node 3 are connected through edge 410 ₂.Also, as illustrated, nodel and node 3 are connected, through node 2.Other nodes are similarly connected.

Edges 410 represent how data from different nodes may be joined togetheri.e., the relationships between data located in different nodes. Suchrelationships may include both one-to-one and one-to-many relationships.Runtime component 114 uses representation 400 and a given abstract queryto identify a sub graph used to generate an abstract query plan. Thatis, while the graph representation 400 represents the entire databaseabstracted by the database abstraction model, only the nodes and edgesnecessary to respond to a given abstract query are needed to create anabstract query plan. Accordingly, the runtime component 114 constructs asub graph from graph representation 400 that includes a minimallynecessary set of nodes and edges. When processing the abstract query,the runtime component 114 only needs the nodes that contain datarelevant to the abstract query.

Most queries, however, will not need data from each node of graphrepresentation 400. Accordingly, FIG. 4B illustrates a modified versionof the database structure from FIG. 4A. The sub graph 430 includes onlythe nodes needed for a particular abstract query. Additionally, thegraph has been altered to remove any repeating paths between nodes. Thisprevents the runtime component 114 from becoming stuck in a repeatingloop while processing an abstract query. Such a path may occur whenedges connect nodes in a cycle. For example, the path: 1→2→5→4→1 is anexample of a cyclic path through the graph representation 400. This pathis severed by removing the edge 410 ₁ between node 1 and node 2. In oneembodiment, any cyclic paths that are present in a sub graph of nodes(e.g., sub graph 430), are severed prior to generating an abstract queryplan.

In one embodiment, the first step in constructing an abstract query planis to create a model of the underlying data representation that includesonly the nodes and edges (in other words, the data and relationshipsbetween data sources) necessary for a particular abstract query. Thenode that includes data related to the model entity for the abstractquery is placed at the root of sub graph 430. For example, the“patients”model entity specified for abstract query 202 illustrated inFIG. 4, specifies that the model entity being queries is the “patient”model entity. Accordingly, demographics node 420 is used as the rootnode for abstract query 420.

In one embodiment, generating sub graph 430 representation may comprisegenerating a Steiner tree representation of the nodes (data sources) andedges (relationships between nodes) needed for an abstract query. Asthose skilled in the art will recognize, a Steiner tree is aminimum-weight connected sub graph that includes a set of requirednodes. The node that includes data related to the model entity for theabstract query is placed at the root of the tree, and the distance tothe terminal nodes is minimized to generate sub graph 430. Asillustrated in FIG. 4B, nodes 420, 422, 424 and 426 are selected. Inthis example, each node selected for the sub graph 430 also containsdata needed to process the query, but this result is not required. Forexample, if abstract query 202 also required data from the “doctors”data source node 428, then the node 432 would be included in thesub-graph 430, even though it would only serve to connect node 428 tothe demographics node 420.

Sub graph representation 430 generated by the runtime component is usingrelationships between data specified in the data repository abstractioncomponent. In one embodiment, a user may be presented with the initialsub graph representation 430 and given the opportunity to modify theinitial graph representation. Alternatively, or in addition, the usermay be presented with an interface allowing the user to specifyadditional, or different, relations between the data sources illustratedin graph 400. For example, as illustrated in sub graph representation430, the demographic data source is connected through the tests datasource to the notes data source. However, the notes data source couldalso be connected through node 8 illustrated in FIG. 4A. This could beadvantageous, for example, where the tests table is very large, makingusing it only for a join process very inefficient. In such a case asophisticated user or database administrator could specify the preferredsub graph representation to use for query processing.

Once sub graph 430 is determined for a particular abstract query, theruntime component 114 generates a set of table instances (described ingreater detail below with respect to FIG. 6). Each table instancecorresponds to a node from the sub graph representation 430. In oneembodiment, an abstract query plan comprises a set of one or more tableinstances along with a set of join relationships and metadata about thejoin relationships. Each table instance may comprise a data structureused by runtime component 114 that includes a combination of bothlogical data from the data abstraction model, and physical data (e.g.,tables and columns) from the underlying physical storage mechanism.

FIG. 5 shows an illustration of one embodiment of a table instance 502data structure. As illustrated, table instance 502 includes fieldssection 506, table section 508, conditions sections 510. Table section508 identifies the underlying physical data source (e.g., a relationaltable, view, or common table expression for a relational data source)where the data corresponding to the fields section 506 is located. Inaddition, conditions section 510 specifies the restrictions on the dataspecified for the logical fields included in the abstract query.

Table instance 502 includes an identifier 504 used to identify eachdistinct table instance. In addition, the identifier 504 may includeattributes that describe the purpose for the table in the abstract queryplan. For example, attributes may classify a table instance as aninformational table that is used to select data returned for an abstractquery (e.g., the results criteria 204 from abstract query 202) or as aconditional table used to represent the conditional restrictionsincluded in the abstract query.

The runtime 114 component is configured to divide conditions and logicalfields specified in the abstract query and group them into units. Eachunit includes the logical fields that are applied against the same datasource. In other words, all of the logical data (e.g., fields andconditions) included in a particular table instance correspond to datapresent in the data source indicated by table section 508 for thespecific table instance. Particular examples of a table instances andthere use as part of an abstract query plan is further described inreference to FIG. 6.

FIG. 6 illustrates an example of an abstract query plan generated fromabstract query 600. Using the database abstraction model 148, and querybuilding interface 120 a user composes abstract query 600 and submits itto the runtime component 114 for processing. In this example, the userhas specified the model entity “patient.” Abstract query 600 includesselection fields of “hemoglobin test” and the result criteria “age>18”and results criteria of patient name and age. Thus, the query shouldretrieve the name and age of any patient with data in the underlyingdatabase who has taken a hemoglobin test, and whose age is greater than18.

Table instance “t1” and “t2” are part of an abstract query plan thatcorresponds to the abstract query 600. Each table includes fieldsections (610 and 616), data source sections (612 and 618), andcondition (614 and 620). Table instance 602 labeled “t1” incorporatesthe selection criteria specified by abstract query 600. Data sourcesection 612 indicated that all of the logical fields included in thistable instance 602 depend on data from the demographic node (e.g., node420 illustrated in FIG. 4B). As illustrated, table 602 includes anattribute 603 indicating that the table instance is an informationaltable (i.e., a data source section 612 stores data that will be includedin user results). Field selection data 610 includes “Name,” a simplelogical field that maps to a patient's name, and “C1,” used to represent“composed field one” identified as an Age logical field composed frombirthdate. As illustrated, these fields are decorated with a superscript“s” signifying that the field is used to select data returned to a user.When implemented for execution in a computer system (e.g., server system110), these attributes are stored as part of the data structure used torepresent a table instance. Condition section 614 includes the group ofconditions used to restrict the data selected from data source 612, inthis case, the age condition restriction and the “demographic” datasource 612.

Table instance 604 is labeled with the identifier “t2” and incorporatesthe selection conditions from abstract query 600 in the abstract queryplan. Table attribute 605 indicates that the table is a conditionaltable, i.e., it corresponds to the selection conditions included in theabstract query. In one embodiment, where the abstract query plan is usedto build an SQL query of a relational DBMS, conditional tables maybecome part of the “where” clause for the SQL statement. Fields section616 includes the “Test1” and “ID” fields. The data source for tableinstance 604 is the “tests” table 618. In addition, the conditionsection 620 includes the “type=‘1243’” condition that is not directlyspecified by the query. This condition, however, is implicitly includedin the query from the “hemoglobin” test logical field that maps to datausing a filtered field.

The two table instances are joined by the join relationship 630. Thejoin between the demographic table instance 602 and the tests tableinstance 604 is a one-to-many relationship. That is, each patient (themodel entity) may have many tests. In one embodiment, relationshipsbetween logical fields may be specified in the data abstraction model148. The abstract query plan illustrated in FIG. 6A depicts thisrelationship using the single line segment 632 and double line segment634. In addition, the join relationship includes a join type attribute638. As illustrated, the join indicates a “left” join.

Those skilled in the art will recognize a “left” join as a common typeof relationship between tables in a relational database, and that otherjoin types may be “right” or “inner,” depending on the abstract querybeing processed. The join type indicates how to bind data together,across table instances without repeating all of the data in every table.Attribute 636 (illustrated using the Roman numeral “II”) indicates tothe runtime component that the data is being selected from a filteredfield. When generating a resolved query for a filtered field, theruntime component 114 may be configured to generate a sub-selectstatement from the data source indicated by the table instance. Asillustrated, the tests data source 618 may include test results frommany types of tests, including the hemoglobin test referenced by one ofthe selection logical fields of abstract query 600. The filtered field“hemoglobin test” is used to retrieve only hemoglobin test results fromthis test's data source using the filtered condition 620; namely,“type=1243.”

Those skilled in the art will recognize that the abstract query planillustrated in FIG. 6 is illustrative, and generated from the specificabstract query 600. The abstract query plan generated for other abstractqueries will depend on the information included in each particularabstract query.

Once constructed, the abstract query plan may be optimized prior togenerating a resolved query statement. As described above, one goal increating the abstract query plan is to generate as efficient a resolvedquery as possible given the information available to the runtimecomponent 114. Accordingly, in one embodiment the runtime component maymake multiple passes over the abstract query plan to perform any numberof different optimizations on the abstract query plan.

Additionally, users may be presented with the abstract query plan andgiven the opportunity to select what optimizations to perform, or tomodify the abstract query plan directly. For example, if the abstractquery plan generated by the runtime component creates an abstract queryplan with multiple table instances of a large table (e.g., a teststable), then one user selected optimization would allow a user to directthe runtime component 114 to minimize the number of table instances forthe large table. Or the user may specify a different set of conditionsto use when generating the abstract query plan. Because multipleabstract query plans may be possible, a user may be presented with theopportunity to trade off the benefits of competing plans to select theone that will be the most efficient. For example, if both a tests table(large) and a diagnosis table (small) are available, joining through thesmall table may be the more efficient choice.

Another possible optimization is to transform a set of filtered fieldsspecified for an abstract query into a single query without the filter.This optimization would be useful where a user composes an abstractquery using the same filtered field multiple times. Generally, when usedto query a relational database filtered fields resolve to a sub selectSQL query statement. Performing the same sub select statement multipletimes, however, is highly inefficient. Accordingly, another optimizationwould be to create a common table expression for the filtered fieldinstead of the multiple sub select statements. Those skilled in the artwill recognize that the optimizations described above are exemplary, andfurther, that once constructed, the abstract query plan provides aplatform for many different optimizations that may be selected by a useror by the runtime component 114 inspecting the abstract query plan priorto creating the resolved query.

Once the abstract query plan is constructed, the runtime component 114generates a query of the underlying physical data storage mechanism.Where this comprises a relational DBMS, the runtime component traversesthe abstract query plan to generate an SQL statement. In one embodiment,the runtime component 114 may traverse through the table instances togenerate SQL fragments for each table instance, and then join theinstances together as specified in the join relationships determined forthe abstract query for the abstract query plan.

To complete the processing of the illustrative abstract query plandepicted in FIG. 6, the runtime component 114 traverses the abstractquery plan to generate SQL statement 640. The runtime component 114begins at table instance 602 that includes the model entity for theabstract query plan. From table instance 602, the runtime component 114generates a portion of the resolved query 640 that includes theselection criteria of name and age. Next, the runtime component 114generates SQL statements to include the conditions specified inconditional table instance 604.

The abstract query plan thereby provides a set of discrete objects tiedto both the abstract logical fields and the underlying physical datasources. Rather than attempt to create a resolved query directly, theabstract query plan provides an intermediate representation of theabstract query. This intermediate representation provides a formal datastructure that may be systematically traversed to generate the correctresolved query from any abstract query.

Operational Methods

FIG. 7 illustrates a flow diagram of the operations 700 of runtimecomponent 114 to process an abstract query. Operations 700 correspond tothe transformation illustrated in FIG. 3 of the abstract query 305,intermediate representation 310, and the resolved query 312. The methodbegins at step 702 wherein the runtime component 114 receives, from arequesting entity, an abstract query. The query is composed using querybuilding interface 115, or may also be a saved query composed earlier,by the same or different users. In this way the same abstract query maybe used for different underlying databases. That is, the same logicalfields may be constructed over different underlying databaserepresentations by changing the access methods to account for the sameinformation stored using a different schema or underlying storagemechanism. The abstraction provided by the logical fields and dataabstraction model hides the differences in the underlying systems.

Next, at step 704, the runtime component 114 generates an abstract queryplan from the abstract query. In one embodiment, the abstract query plancomprises a set of table instances constructed from a given abstractquery and a sub graph of the underlying physical database. Next, theruntime component 114 traverses the abstract query plan to generate aquery consistent with the storage format of the underlying data storagemechanisms. For example, where the underlying storage mechanism is arelational database, the runtime component 114 generates an SQLstatement provided to the relational DBMS for execution. Once theabstract query plan is complete, the runtime component 114 may traversethrough the abstract query plan, beginning at the model entity rootnode, to generate a resolved query of the underlying physical database.

FIG. 8 illustrates a method for generating an abstract query plan,according to one embodiment of the invention. The method begins at step810 after runtime component 114 has received an abstract query. Asdescribed above, the abstract query may be composed using query buildinginterface 115. At step 810, each logical field included in an abstractquery is identified, and the definition for the field is retrieved fromthe data abstraction module 148. Next, at step 820, the runtimecomponent retrieves a graph representation of the underlying physicaldatabase, like the graph structures illustrated in FIGS. 4A and 4B. Fromthis representation the runtime component 114 creates an acyclic modelof the database that includes all the nodes required either as datasource or conditional requirements of the query, and may include anybackbone nodes needed to connect to nodes of the query.

At step 830, the node in the graph representation corresponding to themodel entity being queried is identified. As described above, eachabstract query is focused on a model entity depending on the focus ofthe query desired by a user. The data abstraction model 148 defines howthe model entity is related to data in the underlying physical datastorage (e.g., a column from a relational table). Once identified, theruntime component 114 constructs a set of table instances correspondingto the nodes of the sub graph, logical fields, and conditions specifiedeither by the query directly or implicitly as part of a filtered orcomposed logical field. The runtime component completes the abstractquery plan by joining the table instances according to the joinrelationships provided by the graph representation of the database, andany relationship data provided by data abstraction model.

At step 850, after the abstract query plan is completed, the runtimecomponent 114 traverses the abstract query plan to generate a resolvedquery from each table instance, joined according to the identified joinrelationships. This resolved query is supplied to the DBMS managing theunderlying data source (e.g., a relational database) for execution. Inone embodiment, multiple query fragments may be generated and processedby the DBMS 116. In such an embodiment, the runtime component may beconfigured to merge the results generated from each sub query. At step870, the results may be formatted and returned to the user. In oneembodiment, this may comprise returning a set of query results formattedas HTML for web browser 122. Alternatively, this may comprise returningresults to application 120 that displays the results, or may alsoperform additional analysis, such as a statistical analysis configuredto issue an abstract query and analyze the results.

While the foregoing is directed to embodiments of the present invention,other and further embodiments of the invention may be devised withoutdeparting from the basic scope thereof, and the scope thereof isdetermined by the claims that follow.

1. A method of processing an abstract query, comprising: receiving, froma requesting entity, an abstract query composed from a plurality oflogical fields, wherein each logical field specifies (i) a name used toidentify the logical field, (ii) an access method that maps the logicalfield to a data source in a database; identifying (i) a set of datasources referenced by the plurality of logical fields in the abstractquery and (ii) a set of relationships between the set of data sources;determining an acyclic graph representation of the set of data sources;generating an abstract query plan, wherein the abstract query plancomprises: (a) a plurality of table instances, wherein each tableinstance includes: (i) an indication of a data source associated withthat table instance; (ii) each of the logical fields included in theabstract query that depend on data present in the indicated data source;and (iii) conditions used to limit data selected from the indicated datasource; and (b) a set of join relationships that indicates how theplurality of table instances are related to one another; performing atleast one optimization of the abstract query plan to generate anoptimized abstract query plan; and traversing the optimized abstractquery plan to generate a resolved query of the set of data sources. 2.The method of claim 1, wherein the optimization comprises (i) modifyingthe set of join relationships or (ii) reducing a number of identicaltable instances included in the abstract query plan.
 3. The method ofclaim 1, further comprising, providing the resolved query to the adatabase management system configured to manage the data stored in thedatabase; receiving a set of query result data; and returning the set ofquery result data to the requesting entity.
 4. The method of claim 1,wherein the graph representation of the relational database comprises agraph representation wherein each node represents a data source, andeach edge represents a relationship between data sources.
 5. The methodof claim 1, wherein the set of data sources comprise a set of tables ina relational database and wherein the set of relationships between thedata sources comprise primary key and foreign key relationships.
 6. Themethod of claim 1, wherein the database comprises a federated databasedefined using a relational schema constructed from a plurality ofindividual relational databases.
 7. The method of claim 1, whereinacyclic graph representation of the set of data sources comprises aSteiner tree representation, wherein the root node of the Steiner treecorresponds to a model entity identified by the abstract query.
 8. Themethod of claim 1, wherein the access method for each logical field isselected from one of a simple, filtered, or composed access method. 9.The method of claim 1, wherein creating a resolved query of the set ofdata comprises generating an SQL statement.
 10. The method of claim 1,wherein the query building interface comprises a web-based interfaceaccessed using an internet web browser application.